﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.ComponentModel;

namespace LEDShow.Controls
{
    /// <summary>
    /// NamePlateControl.xaml 的交互逻辑
    /// </summary>
    public partial class NamePlateControl : UserControl, INotifyPropertyChanged
    {
        #region 公共属性
        private string _position = "职务";
        public string Position
        {
            get { return _position; }
            set
            {
                if (value == _position)
                    return;

                _position = value;

                InitByPosition();

                OnPropertyChanged("Position");
            }
        }

        private string _jobNum;
        public string JobNum
        {
            get { return _jobNum; }
            set
            {
                if (_jobNum == value)
                    return;

                _jobNum = value;

                OnPropertyChanged("JobNum");
            }
        }


        private string _userName;
        public string UserName
        {
            get { return _userName; }
            set
            {
                if (value == _userName)
                    return;

                _userName = value;

                OnPropertyChanged("UserName");
            }
        }

        private string _trainID;
        public string TrainID
        {
            get { return _trainID; }
            set
            {
                if (value == _trainID)
                    return;

                _trainID = value;

                OnPropertyChanged("TrainID");
            }
        }

        private Visibility _trainID_visibity = Visibility.Visible;
        public Visibility TrainID_visibity
        {
            get { return _trainID_visibity; }
            set
            {
                if (_trainID_visibity == value)
                    return;

                _trainID_visibity = value;

                OnPropertyChanged("TrainID_visibity");
            }
        }

        private SolidColorBrush _backGround = Brushes.Transparent;
        private SolidColorBrush BackGround
        {
            get { return _backGround; }
            set
            {
                if (_backGround == value)
                    return;

                _backGround = value;
                OnPropertyChanged("BackGround");
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        public virtual void OnPropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = this.PropertyChanged;
            if (null != handler)
            {
                var e = new PropertyChangedEventArgs(propertyName);
                handler(this, e);
            }
        }
        #endregion

        private SolidColorBrush _teamLeaderBackground = Brushes.Gold;
        private SolidColorBrush _pbyBackground = Brushes.Blue;

        public NamePlateControl()
        {
            InitializeComponent();

            this.DataContext = this;
        }

        private void InitByPosition()
        {
            if (_position != "电客车司机")
            {
                this.TrainID_visibity = Visibility.Collapsed;
                if (_position == "电客车司机长")
                    this.BackGround = _teamLeaderBackground;
                else if (_position == "派班员"||_position=="督导员")
                    this.BackGround = _pbyBackground;
            }
        }

    }
}
